home *** CD-ROM | disk | FTP | other *** search
/ Apple II Magazines (DO) / Peeker Nr. 15 (1986)(Verlag, Dr. Alfred Huethig)(DE).zip / Peeker Nr. 15 (1986)(Verlag, Dr. Alfred Huethig)(DE).do / FIBTEST.TEXT.txt < prev    next >
Text File  |  1996-12-24  |  9KB  |  301 lines

  1.  
  2. {$I-}
  3. {$R-}
  4. program FibTest (input, output);
  5.  
  6. const Maxunit     =    12;
  7.       Maxdir      =    77;
  8.       Vidleng     =     7;
  9.       Tidleng     =    15;
  10.       Fidleng     =    23;
  11.       Fblksize    =   512;
  12.       Fblkmax     =   511;
  13.  
  14. type  Daterec     = packed record
  15.                       Month : 0..12;
  16.                       Day   : 0..31;
  17.                       Year  : 0..100
  18.                     end; {Daterec}
  19.  
  20.       Unitnum     = 0..Maxunit;
  21.       Vid         = string [Vidleng];
  22.  
  23.       Dirrange    = 0..Maxdir;
  24.       Tid         = string [Tidleng];
  25.       Fid         = string [Fidleng];
  26.       
  27.       Filekind    = (Untypedfile, Xdskfile, Codefile, Textfile,
  28.                      Infofile, Datafile, Graffile, Fotofile,
  29.                      Securedir, Subsvol);
  30.  
  31.       Direntry    = packed record
  32.                       Dfirstblk : integer;
  33.                       Dlastblk  : integer;
  34.                       case Dfkind : Filekind of
  35.                         Securedir,
  36.                         Untypedfile : (Filler_1  : 0..4095;
  37.                                        Dvid      : Vid;
  38.                                        Deovblk   : integer;
  39.                                        Dnumfiles : Dirrange;
  40.                                        Dloadtime : integer;
  41.                                        Dlastboot : Daterec);
  42.                         Xdskfile,
  43.                         Codefile,
  44.                         Textfile,
  45.                         Infofile,
  46.                         Datafile,
  47.                         Graffile,
  48.                         Fotofile,
  49.                         Subsvol     : (Filler_2  : 0..2047;
  50.                                        Dstatus   : boolean;
  51.                                        Dtid      : Tid;
  52.                                        Dlastbyte : 1..Fblksize;
  53.                                        Daccess   : Daterec)
  54.                     end; {Direntry}
  55.  
  56.       Dirp        = ^Directory;
  57.       Directory   = array [Dirrange] of Direntry;
  58.  
  59.       Windowp     = ^Window;
  60.       Window      = packed array [0..0] of char;
  61.  
  62.       Fibp        = ^Fib;
  63.       Fib         = record
  64.                       Fwindow  : Windowp;
  65.                       Feof,
  66.                       Feoln    : boolean;
  67.                       Fstate   : (Fjandw, Fneedchar, Fgotchar);
  68.                       Frecsize : integer;
  69.                       case Fisopen : boolean of
  70.                         true : (Fisblkd   : boolean;
  71.                                 Funit     : Unitnum;
  72.                                 Fvid      : Vid;
  73.                                 Freptcnt,
  74.                                 Fnxtblk,
  75.                                 Fmaxblk   : integer;
  76.                                 Fmodified : boolean;
  77.                                 Fheader   : Direntry;
  78.                                 case Fsoftbuf : boolean of
  79.                                   true : (Fnxtbyte,
  80.                                           Fmaxbyte  : integer;
  81.                                           Fbufchngd : boolean;
  82.                                           Fbuffer   : packed
  83.                                             array [0..Fblksize]
  84.                                             of char))
  85.                     end; {Fib}
  86.  
  87.       Typ         = record
  88.                       X : integer;
  89.                       Y : integer
  90.                     end; {Typ}
  91.  
  92. var   F1          : text;
  93.       F2          : interactive;
  94.       F3          : file of Typ;
  95.       F4          : file;
  96.       Fileinfo    : Fib;
  97.       S           : string;
  98.  
  99. {--------------------------------------------------------------}
  100.  
  101. procedure writelnBool (B : boolean);
  102.  
  103. begin {writelnBool}
  104.   if B
  105.   then write ('true')
  106.   else write ('false');
  107.   writeln
  108. end; {writelnBool}
  109.  
  110. {--------------------------------------------------------------}
  111.  
  112. procedure writelnFstate (State : integer);
  113.  
  114. begin {writelnFstate}
  115.   write ('Fstate      : ');
  116.   case State of
  117.     0 : write ('Fjandw');
  118.     1 : write ('Fneedchar');
  119.     2 : write ('Fgotchar')
  120.   end; {case}
  121.   writeln
  122. end; {writelnFstate}
  123.  
  124. {--------------------------------------------------------------}
  125.  
  126. procedure writeFheader (Header : Direntry);
  127.  
  128. {--------------------------------------------------------------}
  129.  
  130.   procedure writelnKind (Kind : Filekind);
  131.   
  132.   begin {writelnKind}
  133.     write ('Filekind    : ');
  134.     case Kind of
  135.       Untypedfile : write ('Untypedfile');
  136.       Xdskfile    : write ('Xdskfile');
  137.       Codefile    : write ('Codefile');
  138.       Textfile    : write ('Textfile');
  139.       Infofile    : write ('Infofile');
  140.       Datafile    : write ('Datafile');
  141.       Graffile    : write ('Graffile');
  142.       Fotofile    : write ('Fotofile');
  143.       Securedir   : write ('Securedir');
  144.       Subsvol     : write ('Subsvol')
  145.     end; {case}
  146.     writeln
  147.   end; {writelnKind}
  148.   
  149. {--------------------------------------------------------------}
  150.  
  151.   procedure writelnTheDate (Date : Daterec);
  152.   
  153.   begin {writelnDate}
  154.     with Date do writeln (Day, '-', Month, '-', Year)
  155.   end; {writelnDate}
  156.   
  157. {--------------------------------------------------------------}
  158.  
  159.   procedure writelnDir;
  160.   
  161.   begin {writelnDir}
  162.     with Header do
  163.     begin
  164.       writeln ('Directory:');
  165.       writeln ('Dvid        : ', Dvid);
  166.       writeln ('Deovblk     : ', Deovblk);
  167.       writeln ('Dnumfiles   : ', Dnumfiles);
  168.       writeln ('Dloadtime   : ', Dloadtime);
  169.       write   ('Dlastboot   : ');
  170.       writelnTheDate (Dlastboot)
  171.     end {with}
  172.   end; {writelnDir}
  173.   
  174. {--------------------------------------------------------------}
  175.  
  176.   procedure writelnFile;
  177.   
  178.   begin {writelnFile}
  179.     with Header do
  180.     begin
  181.       write   ('Dstatus     : ');
  182.       writelnBool (Dstatus);
  183.       writeln ('Dtid        : ', Dtid);
  184.       writeln ('Dlastbyte   : ', Dlastbyte);
  185.       write   ('Daccess     : ');
  186.       writelnTheDate (Daccess)
  187.     end {with}
  188.   end; {writelnFile}
  189.   
  190. {--------------------------------------------------------------}
  191.  
  192. begin {writeFheader}
  193.   with Header do
  194.   begin
  195.     writeln ('Dfirstblk   : ', Dfirstblk);
  196.     writeln ('Dlastblk    : ', Dlastblk);
  197.     writelnKind (Dfkind);
  198.     case Dfkind of
  199.       Securedir,
  200.       Untypedfile : writelnDir;
  201.       Xdskfile,
  202.       Codefile,
  203.       Textfile,
  204.       Infofile,
  205.       Datafile,
  206.       Graffile,
  207.       Fotofile,
  208.       Subsvol    : writelnFile
  209.     end {case}
  210.   end {with}
  211. end; {writeFheader}
  212.  
  213. {--------------------------------------------------------------}
  214.  
  215. procedure Lookfile (F : Fib);
  216.  
  217. var I     : integer;
  218.     C     : char;
  219.     Ready : boolean;
  220.  
  221. begin {Lookfile}
  222.   with F do
  223.   begin
  224.     writeln ('Fwindow     : ', ord (Fwindow));
  225.     write   ('Feof        : ');
  226.     writelnBool (Feof);
  227.     write   ('Feoln       : ');
  228.     writelnBool (Feoln);
  229.     writelnFstate (ord (Fstate));
  230.     writeln ('Frecsize    : ', Frecsize);
  231.     write   ('Fisopen     : ');
  232.     writelnBool (Fisopen);
  233.     if Fisopen then
  234.     begin
  235.       write   ('Fisblkd     : ');
  236.       writelnBool (Fisblkd);
  237.       writeln ('Fvid        : ', Fvid);
  238.       writeln ('Freptcnt    : ', Freptcnt);
  239.       writeln ('Fnxtblk     : ', Fnxtblk);
  240.       writeln ('Fmaxblk     : ', Fmaxblk);
  241.       write   ('Fmodified   : ');
  242.       writelnBool (Fmodified);
  243.       writeln ('Fheader:');
  244.       writeFheader (Fheader);
  245.       write   ('Fsoftbuf    : ');
  246.       writelnBool (Fsoftbuf);
  247.       if Fsoftbuf then
  248.       begin
  249.         writeln ('Fnxtbyte    : ', Fnxtbyte);
  250.         writeln ('Fmaxbyte    : ', Fmaxbyte);
  251.         write   ('Fbufchngd   : ');
  252.         writelnBool (Fbufchngd);
  253.         writeln ('Fbuffer:');
  254.         I := 0;
  255.         with Fheader do
  256.         while (I <= Fblkmax) and not Ready do
  257.         begin
  258.           if I mod 16 = 0 then writeln;
  259.           C := Fbuffer [I];
  260.           Ready := (Dfkind = Textfile) and (C = chr (0));
  261.           if Dfkind = Textfile
  262.           then write (C : 4)
  263.           else write (ord (C) : 4);
  264.           I := I + 1
  265.         end; {while}
  266.         writeln
  267.       end {if}
  268.     end; {if}
  269.     writeln
  270.   end {with}
  271. end; {Lookfile}
  272.  
  273. {--------------------------------------------------------------}
  274.  
  275. begin {FibTest}
  276.   reset (F1, 'TEXTFILE.TEXT');
  277.   moveleft (F1, Fileinfo, size_of (Fileinfo));
  278.   writeln ('TEXTFILE.TEXT');
  279.   Lookfile (Fileinfo);
  280.   close (F1);
  281.   
  282.   reset (F2, 'INTFILE.TEXT');
  283.   read (F2, S);
  284.   moveleft (F2, Fileinfo, size_of (Fileinfo));
  285.   writeln ('INTFILE.TEXT');
  286.   Lookfile (Fileinfo);
  287.   close (F2);
  288.   
  289.   reset (F3, 'DATAFILE.DATA');
  290.   moveleft (F3, Fileinfo, size_of (Fileinfo));
  291.   writeln ('DATAFILE.DATA');
  292.   Lookfile (Fileinfo);
  293.   close (F3);
  294.   
  295.   reset (F4, 'CODEFILE.CODE');
  296.   moveleft (F4, Fileinfo, size_of (Fileinfo));
  297.   writeln ('CODEFILE.CODE');
  298.   Lookfile (Fileinfo);
  299.   close (F4)
  300. end {FibTest}.
  301.